package data.events
{
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.events.SecurityErrorEvent;
	
	public class SocketBaseEvent extends Event
	{
		/**
		 * 安全错误
		 */		
		public static const SECURITY_ERROR:String = SecurityErrorEvent.SECURITY_ERROR;
		
		/**
		 * 发生输入/输出错误
		 */		
		public static const IO_ERROR:String = IOErrorEvent.IO_ERROR;
		
		/**
		 * 解码错误
		 */		
		public static const DECODE_ERROR:String = "decodeError";
		
		/**
		 *  Socket返回数据
		 */		
		public static const SOCKET_DATA:String = ProgressEvent.SOCKET_DATA;
		
		/**
		 * Socket已发送
		 */		
		public static const SENDING:String = "sending";
		
		/**
		 *Socket关闭 
		 */		
		public static const CLOSE:String = Event.CLOSE;
		
		/**
		 * Socket连接建立
		 */
		public static const CONNECT:String = Event.CONNECT;
		
		/**
		 * Socket通讯工厂外发数据对象注册成功事件
		 */
		public static const REGISTER_COMPLETE:String = "RegisterComplete";
		
		/**
		 *事件传输数据 
		 */		
		private var _data:Object;  

		/**
		 * SocketBase 事件 
		 * @param type 事件类型
		 * @param data 传转数据
		 */		
		public function SocketBaseEvent(type:String, data:Object = null)
		{  
			super(type);  
			_data = data;            
		}
		
		/**
		 * 取得事件传输数据
		 */		
		public function get data():Object
		{
			return _data;  
		}  
		
		override public function toString():String
		{  
			return formatToString("SocketBaseEvent", "type", "bubbles", "cancelable", "data");  
		}  
		
		/**
		 *克隆事件
		 */		
		override public function clone():Event
		{  
			return new SocketBaseEvent(type, data);  
		}  
	}
}